<extend name="_layout/main" />
<block name="head">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/assets/css/jasny-bootstrap.min.css" />
	<style type="text/css">
		#thumb~i,
		{
			display: none!important;
		}
	</style>
</block>
<block name="content">
	<div class="page-content">
		<div class="page-breadcrumbs">
			<ul class="breadcrumb">
				<li>
					<i class="fa fa-home"></i>
					<a href="{:U('dashboard/index')}">系统首页</a>
				</li>
				<li>
					<a href="javascript:;">文章管理</a>
				</li>
				<li class="active">编辑文章</li>
			</ul>
		</div>
		<div class="page-body">
			<div class="row">
				<div class="col-xs-12 col-md-12">
					<div class="widget">
						<div class="widget-header">
							<span class="widget-caption">编辑文章</span>
						</div>
						<div class="widget-body">
							<div>
								<div class="tabbable">
									<ul class="nav nav-tabs" id="myTab">
										<li class="active">
											<a data-toggle="tab" href="#home" aria-expanded="true">
                                                	基本信息
                                            </a>
										</li>

										<li class="tab-red">
											<a data-toggle="tab" href="#seo" aria-expanded="false">
                                               SEO设置
                                            </a>
										</li>

									</ul>
									<form role="form" class="form-horizontal" method="post" id="addForm" enctype="multipart/form-data">
										<input type="hidden" name="id" value="{$id}" />
										<input type="hidden" id="default_photo" name="default_photo" value=""  />
										<div class="tab-content">
											<div id="home" class="tab-pane active">

												<div class="form-group ">
													<label for="title" class="col-sm-2 control-label no-padding-right">标题</label>
													<div class="col-xs-4">
														<input type="text" class="form-control" id="title" name="title" value="{$title}">
													</div>
												</div>
												<div class="form-group ">
													<label for="author" class="col-sm-2 control-label no-padding-right">作者</label>
													<div class="col-xs-4">
														<input type="text" class="form-control" id="author" name="author" value="{$author}">
													</div>
												</div>
												<div class="form-group ">
													<label for="source" class="col-sm-2 control-label no-padding-right">来源</label>
													<div class="col-xs-4">
														<input type="text" class="form-control" id="source" name="source" value="{$source}">
													</div>
												</div>
												<div class="form-group">
													<label for="category_id" class="col-sm-2 control-label no-padding-right">分类</label>
													<div class="col-xs-2">
														<select name="category_id" id="category_id" class="form-control">
															<option value=""></option>
															{$category_list}
														</select>
													</div>
												</div>
												
												<!--<div class="form-group">
													<label for="player" class="col-sm-2 control-label no-padding-right">插入视频</label>
													<div class="col-sm-4">
														<div class=" input-group">
														<input type="text" name="player" id="player" class="form-control" value="{$player}">
														<span class="input-group-btn">
															<input type="button"  id="selectVideo"  class=" btn btn-default copy" value="选择视频" >
														</span>
														</div>
													</div>
												</div>-->
												<div class="form-group">
													<label for="summary" class="col-sm-2 control-label no-padding-right">摘要</label>
													<div class="col-xs-4">
														<textarea class="form-control" rows="5" name="summary">{$summary}</textarea>
													</div>
												</div>
												<div class="form-group">
													<label for="summary" class="col-sm-2 control-label no-padding-right">内容</label>
													<div class="col-xs-6">
														<?php echo form::editor('content',$content,'full')?>
													</div>
												</div>
												<div class="form-group ">
													<label for="thumb" class="col-sm-2 control-label no-padding-right">封面图</label>
													<div class="col-xs-4">
														<div class="fileinput fileinput-new" data-provides="fileinput">
															<div class="fileinput-new thumbnail"> <img data-src="holder.js/200x150?text=封面&theme=gray" src="{$thumb}"  style="max-width: 300px; max-height: 250px;"> </div>
															<div class="fileinput-preview fileinput-exists thumbnail"></div>
															<div> <span class="btn btn-default btn-file"><span class="fileinput-new">选择</span> <span class="fileinput-exists">重新选择</span>
																<input type="file" name="thumb" id="thumb">
																</span> <a href="#" class="btn btn-default fileinput-exists" data-dismiss="fileinput">删除</a> </div>
														</div>

													</div>
												</div>
												<div class="form-group ">
													<label for="top" class="col-sm-2 control-label no-padding-right">是否置顶</label>
													<div class="col-xs-4">
                                                        <div class="checkbox">
                                                            <label>
                                                                <input type="radio" id="top" name="top" value="1" <?php echo $top == 1?'checked="checked"':''; ?> >
                                                                <span class="text">置顶</span>
                                                            </label>                                                                                                                    
                                                        
                                                            <label>
                                                                <input type="radio" id="top" name="top" value="0" <?php echo $top == 0?'checked="checked"':''; ?> >
                                                                <span class="text">不置顶</span>
                                                            </label>
                                                        </div>

													</div>
												</div>
											</div>

											<div id="seo" class="tab-pane">
												<div class="form-group">
													<label for="seo_keywords" class="col-sm-2 control-label no-padding-right">SEO Title</label>
													<div class="col-xs-4">
														<input type="text" class="form-control" name="seo_title" value="{$seo_title}" />
													</div>
												</div>
												<div class="form-group">
													<label for="seo_keywords" class="col-sm-2 control-label no-padding-right">SEO Keywords</label>
													<div class="col-xs-4">
														<textarea class="form-control" rows="5" name="seo_keywords">{$seo_keywords}</textarea>
													</div>
												</div>
												<div class="form-group">
													<label for="seo_description" class="col-sm-2 control-label no-padding-right">SEO Description</label>
													<div class="col-xs-4">
														<textarea class="form-control" rows="5" name="seo_description">{$seo_description}</textarea>
													</div>
												</div>
											</div>

											<div class="row">
												<div class="col-sm-offset-2 col-sm-10">

													<button type="submit" class="btn btn-blue ladda-button" data-style="expand-right" id="submitBtn"> <span class="ladda-label">确认保存</span></button>
												</div>
											</div>
										</div>
									</form>
								</div>

							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</block>

<block name="footer">

	<script src="__PUBLIC__/assets/js/validation/bootstrapValidator.js" type="text/javascript" charset="utf-8"></script>
	<script src="__PUBLIC__/assets/js/select2/select2.js"></script>
	<script src="__PUBLIC__/assets/js/holder.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="__PUBLIC__/assets/js/jasny-bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="__PUBLIC__/assets/js/jquery.form.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		$("#catid").change(function() {
			var type = $(this).find("option:selected").data("type");
			if (type == 2) {
				location.href = "{:U('article/page_add')}?id=" + $(this).val();
			}
		});
		var loader = Ladda.create(document.getElementById("submitBtn"));
		$("#addForm").bootstrapValidator({
			excluded: [':disabled'],
			feedbackIcons: {
				valid: 'glyphicon glyphicon-ok',
				invalid: 'glyphicon glyphicon-remove',
				validating: 'glyphicon glyphicon-refresh'
			},
			submitHandler: function(validator, form, submitButton) {
				loader.start();
				$("#addForm").ajaxSubmit(function(result) {
					loader.stop();
					result = JSON.parse(result);
					if (result.status == 'success') {
						location.href = result.url;
					} else {
						tips(result.message, 'danger');
						validator.disableSubmitButtons(false);
					}
				});
			},
			fields: {
				title: {
					validators: {
						notEmpty: {
							message: '文章标题不能为空'
						}
					}
				},
				category_id: {
					validators: {
						notEmpty: {
							message: '文章分类不能为空'
						}
					}
				}
			}
		});

	</script>
</block>